home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / castools.zip / PHONEBK.H < prev    next >
Text File  |  1990-01-25  |  7KB  |  165 lines

  1. /* FILE: PHONEBK.H      HEADER FILE FOR CAS TOOLKIT PHONEBOOK FUNCTIONS   ====
  2.  
  3.     Defines structures and constants used in the Phonebook libraries of the
  4.     Intel/DCA Communicating Applications Specification 1.0 Toolkit.
  5.  
  6.     This file must be included in any application source files that use
  7.     functions from the CAS Toolkit Phonebook libraries.
  8. ==============================================================================*/
  9.  
  10. /* PHONEBOOK CONSTANTS */
  11. #define FNAMELENGTH     13
  12. #define DIRPATHLENGTH   68
  13. #define NAMELENGTH      32
  14. #define PHONENUMLENGTH  47
  15. #define FULLFNAMELENGTH 80
  16. #define MAXENTRIES      1000
  17. #define MAXFIELDSIZE    60
  18. #define MAXUNUSEDBYTES  32766   /* No, I don't know why this number, see CAS */
  19. #define FAXONLY         0
  20. #define HASCCC          1 /*Has Connection Coprocessor or compatable fax board*/
  21.  
  22. #define SUCCESS          1
  23. #define FAIL             0
  24.  
  25. /* PHONEBOOK STRUCTURES AND TYPE DEFINITIONS*/
  26.  
  27. typedef unsigned char BYTE;
  28. typedef unsigned short WORD;
  29. typedef unsigned long LONGWORD;
  30.  
  31. #pragma pack(1)                         /* To be image of the diskfile data,*/
  32.                                         /* these two structs must be packed */
  33.  
  34. /* PHONEBOOK HEADER STRUCTURE */
  35. typedef struct {
  36.     WORD id;                            /* CAS requires: 1ABBH */
  37.     BYTE MajorVersion;                  /* CCAM Major version number */
  38.     BYTE MinorVersion;                  /* CCAM Minor version number */
  39.     WORD entries;                       /* 0 to 1000 */
  40.     WORD FreeBytes;                     /* unused bytes, 0 to 32766 */
  41.     WORD fields;                        /* vbl-lngth fields in entries: 0-10 */
  42.     char FieldNames[10][15];            /* names of the above fields */
  43. } PBH;                         /* image of the header of the phonebook file on
  44.                                   disk, except for the 4K array of offsets */
  45.  
  46. /* PHONEBOOK ENTRY FIXED PART */
  47. typedef struct {
  48.     int id;                     /* Record ID is the index to the header's
  49.                                     entryOffsets array */
  50.     WORD members;               /* for individual entries, # of groups
  51.                                    for group entries, # of members */
  52.     WORD length;                /* length of this entry, in bytes */
  53.     BYTE type;                  /* PERSONENTRY or GROUPENTRY */
  54.     BYTE HardwareType;          /* For individuals, individual has fax modem.
  55.                                    For groups, all members have fax modems. */
  56.     char name[32];              /* cannot be blank, should be unique */
  57.     char PhoneNumber[47];       /* at least 1 digit or M is required
  58.                                    See manual for legal phone number
  59.                                    characters and their meanings  */
  60. } PBEFIXED;
  61.  
  62. #pragma pack()
  63.  
  64. /* PHONEBOOK STRUCTURE */
  65. typedef struct {
  66.     PBH  header;            /* header without the 4K offset array */
  67.     FILE *fp;               /* stream pointer for phonebook file */
  68.  
  69.     WORD OBufferSize;       /* size of offset cache, 4000 bytes max */
  70.     LONGWORD *OBuffer;      /* NULL or array of 1 to 1000 offsets */
  71.     WORD FirstOBufferRID;   /* record id of first offset currently in buffer */
  72.  } PB;
  73.  
  74. /* PHONEBOOK ENTRY USER STRUCTURE */
  75. typedef struct {
  76.     int id;                     /* Record ID is the index to the header's
  77.                                     entryOffsets array */
  78.     WORD members;               /* for individual entries, # of groups
  79.                                    for group entries, # of members */
  80.     WORD length;                /* length of this entry, in bytes */
  81.     BYTE type;                  /* PERSONENTRY or GROUPENTRY */
  82.     BYTE HardwareType;          /* For individuals, individual has fax modem.
  83.                                    For groups, all members have fax modems. */
  84.     char name[32];              /* cannot be blank, should be unique */
  85.     char PhoneNumber[47];       /* at least 1 digit or M is required
  86.                                    See manual for legal phone number
  87.                                    characters and their meanings  */
  88.     char **fields;              /* 0 - 10  60-character strings. */
  89.     int *MemberList;            /* list of member or group record id's */
  90. } PBE;
  91.  
  92. /* PHONEBOOK GLOBAL VARIABLES */
  93. extern int Pberrno;                     /* defined in PBGLOBAL.H */
  94.  
  95. /*** PHONEBOOK CONSTANTS */
  96.  
  97. /* CCAM VERSION NUMBERS */
  98. #define CCAM_Major     1
  99. #define CCAM_Minor    11
  100.  
  101. /* PHONEBOOK ENTRY CONSTANTS */
  102. #define PERSONENTRY 1
  103. #define GROUPENTRY 2
  104.  
  105. /* MISCELLANEOUS */
  106. #define DISKSPACEMARGIN 1024
  107.  
  108. /* PHONEBOOK ERROR CONSTANTS */
  109. #define      FSEEKERROR      1
  110. #define      OUTOFMEM        2
  111. #define      CANTOPEN        3
  112. #define      CANTWRITE       4
  113. #define      CANTREAD        5
  114. #define      CANTCLOSE       6
  115. #define      ORPHANWARN      7
  116. #define      TOOLONGSTRING   8
  117. #define      FILEALREADYEXISTS 9
  118. #define      FILEDOESNTEXIST 10
  119. #define      OUTOFDISKSPACE  11
  120. #define      INCONSISTENTPBH 12
  121. #define      NOENTRYPRESENT  13
  122. #define      NOENTRYFOUND    14
  123. #define      NOMOREMATCH     15
  124. #define      PHONEBOOKFULL   16
  125. #define      INVALIDENTRY    17
  126. #define      DUPLICATEENTRY  18
  127. #define      FILELENGTHERROR 19
  128. #define      INVALIDCHANGE   20
  129. #define      GROUPNOTEMPTY   21
  130. #define      TOOMANYFREEBYTES 22
  131. #define      GROUPCANTBEMEMBER 23
  132. #define      PERSONCANTHAVEMEMBER 24
  133. #define      ENTRYALREADYMEMBER 25
  134. #define      GROUPDOESNTHAVEMEMBER 26
  135. #define      MEMBERDOESNTHAVEGROUP 27
  136. #define      INVALIDPARAMETER 28
  137. #define      PERSONNOTEMPTY  29
  138. #define      NULLPOINTER     30
  139. #define      LASTMSG         31
  140.  
  141. /* Phonebook function prototypes */
  142.  
  143. extern PB * pascal PbCreatePhonebook(PB *pb, char *name);
  144. extern PB * pascal PbOpenPhonebook(PB *pb, char *name);
  145. extern PB * pascal PbBufferOffsets(PB *pb, LONGWORD *OBuffer, WORD OBufferSize);
  146. extern int pascal  PbGarbageCollect(char *PbFilename);
  147.  
  148. extern int pascal   PbLookUpSendInfo(PB *pb, char *name, int *recordID, char *PhoneNumber, BYTE *CommHardware);
  149. extern PBE * pascal PbFindFirstOrNext(PB *pb, PBE *entry, char *name, int *recordID);
  150. extern PBE * pascal PbGetEntry(PB *pb, PBE *entry, char *name, int RecordID);
  151. extern void pascal PbFreePBE(PB *pb, PBE *entry);
  152.  
  153. extern int pascal PbAddEntry(PB *pb, PBE *entry);
  154. extern int pascal PbModifyEntry(PB *pb, int RecordID, PBE *NewEntry);
  155. extern int pascal PbRemoveEntry(PB *pb, int RecordID);
  156. extern int pascal PbAddToGroup(PB *pb, int GroupID, int MemberID);
  157. extern int pascal PbRemoveFromGroup(PB *pb, int GroupID, int MemberID);
  158.  
  159. /* Phonebook Library utilities */
  160. extern PBEFIXED * pascal GetFixedPart(PB *pb, PBEFIXED *ReturnInfo, WORD rid);
  161. extern char * pascal EntryOkToAdd(PB *pb, PBE *entry);
  162. extern char * pascal EntryOkToChange(PB *pb, PBE *old_entry, PBE *NewEntry);
  163. extern LONGWORD pascal OffsetOfEntry(PB *pb, WORD rid);
  164. extern BYTE pascal HardwareTypeOf(PB *pb, WORD rid, LONGWORD *offset);
  165.